﻿@page
@model AdminUI.Pages.Dialog.SelectAccountModel
@{
    var id = Request.Query["id"];
}

@section body {

    <f:Panel ID="Panel1" ShowBorder="false" ShowHeader="false" BodyPadding="10" Layout="Fit" IsViewPort="true">
        <Toolbars>
            <f:Toolbar ID="Toolbar1">
                <Items>
                    <f:Button ID="btnClose" Icon="SystemClose" Text="关闭">
                        <Listeners>
                            <f:Listener Event="click" Handler="F.activeWindow.hide();"></f:Listener>
                        </Listeners>
                    </f:Button>
                    <f:Button ID="btnSubmit" Text="确定" Icon="SystemSave" OnClickParameter1="@(new Parameter("selectedRowIDs","F.ui.Grid1.getSelectedRows()"))">
                        <Listeners>
                            <f:Listener Event="click" Handler="onConfirmClick"></f:Listener>
                        </Listeners>
                    </f:Button>
                    <f:ToolbarFill></f:ToolbarFill>
                    <f:DropDownList ID="ddlCondition" SelectedValue="" Width="150">
                                <f:ListItem Text="== 请选择条件 ==" Value="" />
                                <f:ListItem Text="姓名" Value="TrueName" />
                                <f:ListItem Text="手机号" Value="Mobile" />
                            </f:DropDownList>
                            <f:TriggerBox ID="ttbSearch" ShowLabel="false" EmptyText="请输入搜索关键字" TriggerIcon="Search" OnTriggerClick="@Url.Handler("Grid_DoAction")" OnTriggerClickFields="Panel1"
                                          OnTriggerClickParameter1="@(new Parameter("actionType", "search", ParameterMode.String))"
                                          OnTriggerClickParameter2="@(new Parameter("searchText", "F.ui.ttbSearch.getValue()"))"
                                          OnTriggerClickParameter3="@(new Parameter("searchCondition", "F.ui.ddlCondition.getValue()"))">
                            </f:TriggerBox>
                </Items>
            </f:Toolbar>
        </Toolbars>
        <Items>
            <f:Grid ID="Grid1" BoxFlex="1" ShowBorder="true" ShowHeader="false" EnableColumnLines="true" EnableCheckBoxSelect="true" EnableMultiSelect="false" DataIDField="UserID" DataTextField="TrueName"
                    AllowPaging="true" PageSize="@ViewBag.PageSize" IsDatabasePaging="true" OnPageIndexChanged="@Url.Handler("Grid_DoAction")" OnPageIndexChangedFields="Panel1"
                    DataSource="@ViewBag.DataSource" RecordCount="@ViewBag.Total" SelectedRowID="@id" >
                <Columns>
                    <f:RenderField HeaderText="会员用户ID" DataField="UserID" FieldType="Int" QuickSortField="true" Width="120" TextAlign="Center" />
                    <f:RenderField HeaderText="会员姓名" DataField="TrueName" Width="120" />
                    <f:RenderField HeaderText="手机号" DataField="Mobile" Width="150" TextAlign="Center" />
                    @* <f:RenderField HeaderText="地址" DataField="Address" Width="220" /> *@
                    @* <f:RenderCheckField HeaderText="启用" DataField="IsEnable" RenderAsStaticField="true" Width="50" TextAlign="Center" /> *@
                    <f:RenderField HeaderText="备注" DataField="Memo" Width="100" ExpandUnusedSpace="true" />
                </Columns>
                <PageItems>
                    <f:ToolbarSeparator></f:ToolbarSeparator>
                    <f:ToolbarText Text="每页记录数："></f:ToolbarText>
                    <f:DropDownList ID="ddlGridPageSize" Width="60" SelectedValue="@ViewBag.PageSize" OnSelectedIndexChanged="@Url.Handler("Grid_DoAction")" OnSelectedIndexChangedParameter1="@(new Parameter("actionType","changePageSize",ParameterMode.String))" OnSelectedIndexChangedFields="Panel1">
                        <Items>
                            <f:ListItem Text="5" Value="5"></f:ListItem>
                            <f:ListItem Text="10" Value="10"></f:ListItem>
                            <f:ListItem Text="20" Value="20"></f:ListItem>
                            <f:ListItem Text="30" Value="30"></f:ListItem>
                            <f:ListItem Text="50" Value="50"></f:ListItem>
                            <f:ListItem Text="100" Value="100"></f:ListItem>
                        </Items>
                    </f:DropDownList>
                </PageItems>
                <Listeners>
                    <f:Listener Event="rowdblclick" Handler="onGridRowDblClick"></f:Listener>
                </Listeners>
            </f:Grid>
        </Items>
    </f:Panel>

    

}

@section script {

    <script src="~/res/js/grid.js"></script>
    <script>
        function onConfirmClick(event) {
            var selectRow = F.ui.Grid1.getSelectedRow(true);

            var activeWindow = F.getActiveWindow();
            activeWindow.hide();
            activeWindow.window.updateUserSelectValue(selectRow.id, selectRow.text);
        }

        function onGridRowDblClick(event, rowId) {
            var grid1 = F.ui.Grid1;
            var selectRow = grid1.getRowData(rowId);
            //var column = grid1.getColumn(grid1.getSelectedCell()[1]);

            //// 触发后台事件
            //F.doPostBack('@Url.Handler("Grid_RowDblClick")', {
            //    rowId: selectRow.id,
            //    rowText: selectRow.text,
            //    rowIndex: selectRow.index,
            //    columnText: column.text
            //});

            var activeWindow = F.getActiveWindow();
            activeWindow.hide();
            activeWindow.window.updateUserSelectValue(selectRow.id, selectRow.text);
        }
    </script>
}

